﻿using System;
using System.Collections.Generic;
using System.Text;
using GISDataAdapter.Data.Object.IO.Structure;
using GISDataAdapter.Data.Type;

namespace GISDataAdapter.Data.Object.Reader
{
    class CharacterFieldReader : IFieldReader
    {
        public CharacterFieldReader(int fieldByteLength)
        {
            this._fieldByteLength = fieldByteLength;
        }

        private int _fieldByteLength;

        #region IFieldReader 成员

        DataType IFieldReader.FieldDataType
        {
            get { return GISDataAdapter.Data.Type.DataType.Character; }
        }

        int IFieldReader.FieldByteLength
        {
            get { return this._fieldByteLength; }
        }

        FieldContainer IFieldReader.Reader(byte[] dbf, int startOffset)
        {
            object value = Encoding.GetEncoding("GB2312").GetString(dbf, startOffset, this._fieldByteLength);
            FieldContainer container = new FieldContainer(value, this._fieldByteLength);
            return container;
        }

        #endregion
    }
}
